//
//  TSKHomeViewController.swift
//  aj
//
//  Created by leeqb on 11/22/15.
//  Copyright © 2015 powerlee. All rights reserved.
//

import UIKit

class TSKHomeViewController: ViewPagerController, ViewPagerDelegate, ViewPagerDataSource {

    override func viewDidLoad() {
        /*let pagerController = ViewPagerController()
        pagerController.delegate = self
        pagerController.dataSource = self
        
        self.addChildViewController(pagerController)
        self.view.addSubview(pagerController.view)
        pagerController.reloadData()*/
        self.delegate = self
        self.dataSource = self
        //self.reloadData()
        
        AJBaseController.addWhiteStatusBar(self)
        
        super.viewDidLoad()
    }
    
    //MARK: - ViewPagerDataSource
    func numberOfTabsForViewPager(viewPager: ViewPagerController!) -> UInt {
        return 10
    }
    
    func viewPager(viewPager: ViewPagerController!, viewForTabAtIndex index: UInt) -> UIView! {
        let label = UILabel()
        label.backgroundColor = UIColor.clearColor()
        label.font = UIFont.systemFontOfSize(15)
        label.text = "标签 #\(index)"
        label.textAlignment = NSTextAlignment.Center
        label.textColor = UIColor.blackColor()
        label.sizeToFit()
        return label
    }
    
    func viewPager(viewPager: ViewPagerController!, contentViewControllerForTabAtIndex index: UInt) -> UIViewController! {
        let vc = UIViewController()
        vc.view.backgroundColor = UIColor.greenColor()
        return vc
    }
    
    //MARK: - ViewPagerDelegate
    func viewPager(viewPager: ViewPagerController!, valueForOption option: ViewPagerOption, withDefault value: CGFloat) -> CGFloat {
        switch(option) {
        case ViewPagerOption.StartFromSecondTab:
            return 1
        case ViewPagerOption.CenterCurrentTab:
            return 0
        case ViewPagerOption.TabLocation:
            return 1
        default:
            return value
        }
    }
    
    func viewPager(viewPager: ViewPagerController!, colorForComponent component: ViewPagerComponent, withDefault color: UIColor!) -> UIColor! {
        switch(component) {
        case ViewPagerComponent.Indicator:
            return UIColor.redColor().colorWithAlphaComponent(0.64)
        default:
            return color
        }
    }
    
}
